import { OrthographicCamera } from "three";
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';

export default class CameraView {

    constructor() {
        
    }

    get control() {
        return this.trackCtrl;
    }

    dispose() {
        if(this.trackCtrl) {
            this.trackCtrl.dispose();
            this.trackCtrl = null;
        }
    }

    createNormalControls(pcamera, domElement) {

        this.dispose();

        this.trackCtrl = new OrbitControls(pcamera, domElement);

        this.trackCtrl.enableDamping = true;
        this.trackCtrl.dampingFactor = 0.05;

        this.trackCtrl.screenSpacePanning = false;

        this.trackCtrl.minDistance = 10;
        this.trackCtrl.maxDistance = 1500;

        this.trackCtrl.target.set(0, 0, 0);
        this.trackCtrl.update();
    }

    createDrawControls( domElement) {

        this.dispose();

        this.ocamera = new OrthographicCamera(
            -window.innerHeight/2, window.innerHeight/2,
            window.innerWidth /2, -window.innerWidth /2
        )

        this.ocamera.position.set(0, 100, 0);

        this.trackCtrl = new OrbitControls( this.ocamera, domElement);

        this.trackCtrl.enableDamping = true;
        this.trackCtrl.dampingFactor = 0.05;


        this.trackCtrl.enableRotate = false;

        this.trackCtrl.screenSpacePanning = false;

        this.trackCtrl.minDistance = 1;
        this.trackCtrl.maxDistance = 1500;

        this.trackCtrl.target.set(0, 0, 0);
        this.trackCtrl.update();
    }

    createRoamControls() {
       
    }

}